#include "process.h"
#include <time.h>
#include <stdlib.h>
#include <unistd.h>

#define FILESIZE 1024*1024*1024
//模拟文件大小1G

///模拟一种下载

void download()
{
	int total = FILESIZE;
	srand(time(NULL));
	while (total )
{
	    usleep(100000);	
		int v = rand() % (1024 * 1024 * 10);
     	total -= v;
	    if (total < 0)
	    	total = 0;
		double rate = (FILESIZE - total) * 1.0 / (FILESIZE)*100;
        process(rate);                
        //		printf("%lf%%\r", rate);
        //		fflush(stdout);
}

}

int main()
{
    download();
    return 0;
}
